/* 竞赛获奖信息统计(新增部分) */
<template>
    <div>
        <div style="height: 30px;">
            <el-breadcrumb style="float: left;" separator="/">
                <el-breadcrumb-item :to="{ path: '/competiInformaStatistics' }">
                    <span @click="reback">{{ $t('statisticsOfAwards.statisticsAwards') }}</span>
                </el-breadcrumb-item>
                <el-breadcrumb-item>{{ compile }}</el-breadcrumb-item>
            </el-breadcrumb>
        </div>

        <el-card v-loading="loading" shadow="never" body-style="padding: 10px;">
            <condition-card
                label-position="right"
                label-width="150px"
                style="border: none;"
                @reset="reset"
                @search="onSubmit"
            >
                <el-row style="height: 50px;">
                     <!-- 年份 -->
                    <el-col :span="8">
                        <el-form-item :label="$t('statisticsOfAwards.year')">
                            <el-date-picker v-model="queryForm.condition.year" value-format="yyyy" type="year" :editable="editable" :placeholder="$t('placeholderTips.selectGrade')" style="width: 100%" />
                        </el-form-item>
                    </el-col>
                    <!-- 学院 -->
                    <el-col :span="8">
                        <el-form-item :label="$t('label.college')">
                            <!-- <DictSelect v-model="queryForm.departmentId" :data="options.departmentId" :clearable="true" ></DictSelect> -->
                            <DictSelect :labelAll="$t('statisticsOfAwards.whole')" v-model="queryForm.condition.college" filterable :data="options.departmentId" :clearable="true" ></DictSelect>
                        </el-form-item>
                    </el-col>
                    <!-- 年级 -->
                    <el-col :span="8">
                        <el-form-item :label="$t('statisticsOfAwards.grade')">
                            <el-date-picker
                                v-model="queryForm.condition.grade"
                                value-format="yyyy"
                                type="year"
                                :placeholder="$t('statisticsOfAwards.selectYear')"
                                style="width:100%"
                            >
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>
            </condition-card>
            <el-card v-loading="loading" shadow="never" body-style="padding: 24px;" style="margin: 0;border: none;">
                <el-row style="padding:15px;" type="flex" class="row-bg" justify="end">
                    <h1 class="condition-title" style="float:left;margin-top: 5px; width:100%;">{{ $t('statisticsOfAwards.awardStatistics') }}</h1>
                    <!-- <el-dropdown placement='bottom-start' trigger="click" @command="downloadFile">
                        <el-button type="primary">{{$t('internship.lead')}}<i class="el-icon-arrow-down el-icon--right"></i></el-button>
                        <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item command="导入">{{$t('导入数据')}}</el-dropdown-item>
                        <el-dropdown-item command="下载">{{$t('internship.download')}}</el-dropdown-item>
                        </el-dropdown-menu>
                    </el-dropdown> -->
                    <el-button  type="primary" style="float:right; margin-left:10px;"  @click="exportFile">{{ $t('statisticsOfAwards.export') }}</el-button>
                    <el-button style="float:right; margin-left:10px;" @click="reback">{{ $t('statisticsOfAwards.goBack') }}</el-button>
                </el-row>
                <hr style="margin-top: 0;border-top: 2px solid #eee;">
                <el-tabs v-model="activeName" type="border-card" @tab-click="handleClick">
                    <el-tab-pane :label="$t('statisticsOfAwards.year')" name="year">
                        <el-table
                            :pagination="false"
                            :selection="false"
                            :tooltip-effect="tooltipEffect"
                            :data="dataList"
                            :order="false"
                            stripe
                            size="mini"
                        >
                            <el-table-column align='center' :label="$t('statisticsOfAwards.year')" prop="year" show-overflow-tooltip></el-table-column>
                            <el-table-column align='center' :label="$t('statisticsOfAwards.numberOfEntries')" show-overflow-tooltip>
                                <el-table-column :label="$t('statisticsOfAwards.international')" prop="internationalProject" show-overflow-tooltip></el-table-column>
                                <el-table-column :label="$t('statisticsOfAwards.country')" prop="countryProject" show-overflow-tooltip></el-table-column>
                                <el-table-column :label="$t('statisticsOfAwards.provincial')" prop="provinceProject" show-overflow-tooltip></el-table-column>
                                <el-table-column :label="$t('statisticsOfAwards.municipal')" prop="cityProject" show-overflow-tooltip></el-table-column>
                                <el-table-column :label="$t('statisticsOfAwards.schoolLevel')" prop="schoolProject" show-overflow-tooltip></el-table-column>
                                <el-table-column :label="$t('statisticsOfAwards.total')" prop="sumProject" show-overflow-tooltip></el-table-column>
                            </el-table-column>
                            <el-table-column align='center' :label="$t('statisticsOfAwards.internationalLevel')" show-overflow-tooltip>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.specialGrade')" prop="topInternationalLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.firstGrade')" prop="firstInternationalLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.secondGrade')" prop="secondInternationalLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.ThirdGrade')" prop="thirdInternationalLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.otherGrade')" prop="otherInternationalLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column :label="$t('statisticsOfAwards.total')" prop="sumInternationalLevel" show-overflow-tooltip></el-table-column>
                            </el-table-column>
                            <el-table-column align='center' :label="$t('statisticsOfAwards.countryLevel')" show-overflow-tooltip>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.specialGrade')" prop="topCountryLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.firstGrade')" prop="firstCountryLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.secondGrade')" prop="secondCountryLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.ThirdGrade')" prop="thirdCountryLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.otherGrade')" prop="otherCountryLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.total')" prop="sumCountryLevel" show-overflow-tooltip></el-table-column>
                            </el-table-column>
                            <el-table-column align='center' :label="$t('statisticsOfAwards.provincialLevel')" show-overflow-tooltip>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.specialGrade')" prop="topProvinceLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.firstGrade')" prop="firstProvinceLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.secondGrade')" prop="secondProvinceLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.ThirdGrade')" prop="thirdProvinceLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.otherGrade')" prop="otherProvinceLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column :label="$t('statisticsOfAwards.total')" prop="sumProvinceLevel" show-overflow-tooltip></el-table-column>
                            </el-table-column>
                            <el-table-column align='center' :label="$t('statisticsOfAwards.municipal')" show-overflow-tooltip>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.specialGrade')" prop="topCityLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.firstGrade')" prop="firstCityLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.secondGrade')" prop="secondCityLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.ThirdGrade')" prop="thirdCityLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.otherGrade')" prop="otherCityLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column :label="$t('statisticsOfAwards.total')" prop="sumCityLevel" show-overflow-tooltip></el-table-column>
                            </el-table-column>
                            <el-table-column align='center' :label="$t('statisticsOfAwards.schoolLevel')" prop="sumSchoolLevel" show-overflow-tooltip></el-table-column>
                        </el-table>
                    </el-tab-pane>
                    <el-tab-pane :label="$t('statisticsOfAwards.college')" name="college">
                        <el-table
                            :pagination="false"
                            :selection="false"
                            :tooltip-effect="tooltipEffect"
                            :data="dataList"
                            :order="false"
                            stripe
                            size="mini"
                        >
                            <el-table-column align='center' :label="$t('statisticsOfAwards.year')" prop="year" show-overflow-tooltip></el-table-column>
                            <el-table-column width="120%" align='center' :label="$t('statisticsOfAwards.college')" prop="collegeName" show-overflow-tooltip></el-table-column>
                            <el-table-column align='center' :label="$t('statisticsOfAwards.numberOfEntries')" show-overflow-tooltip>
                                <el-table-column :label="$t('statisticsOfAwards.international')" prop="internationalProject" show-overflow-tooltip></el-table-column>
                                <el-table-column :label="$t('statisticsOfAwards.country')" prop="countryProject" show-overflow-tooltip></el-table-column>
                                <el-table-column :label="$t('statisticsOfAwards.provincial')" prop="provinceProject" show-overflow-tooltip></el-table-column>
                                <el-table-column :label="$t('statisticsOfAwards.municipal')" prop="cityProject" show-overflow-tooltip></el-table-column>
                                <el-table-column :label="$t('statisticsOfAwards.schoolLevel')" prop="schoolProject" show-overflow-tooltip></el-table-column>
                                <el-table-column :label="$t('statisticsOfAwards.total')" prop="sumProject" show-overflow-tooltip></el-table-column>
                            </el-table-column>
                            <el-table-column align='center' :label="$t('statisticsOfAwards.internationalLevel')" show-overflow-tooltip>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.specialGrade')" prop="topInternationalLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.firstGrade')" prop="firstInternationalLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.secondGrade')" prop="secondInternationalLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.ThirdGrade')" prop="thirdInternationalLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.otherGrade')" prop="otherInternationalLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column :label="$t('statisticsOfAwards.total')" prop="sumInternationalLevel" show-overflow-tooltip></el-table-column>
                            </el-table-column>
                            <el-table-column align='center' :label="$t('statisticsOfAwards.countryLevel')" show-overflow-tooltip>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.specialGrade')" prop="topCountryLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.firstGrade')" prop="firstCountryLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.secondGrade')" prop="secondCountryLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.ThirdGrade')" prop="thirdCountryLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.otherGrade')" prop="otherCountryLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.total')" prop="sumCountryLevel" show-overflow-tooltip></el-table-column>
                            </el-table-column>
                            <el-table-column align='center' :label="$t('statisticsOfAwards.provincialLevel')" show-overflow-tooltip>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.specialGrade')" prop="topProvinceLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.firstGrade')" prop="firstProvinceLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.secondGrade')" prop="secondProvinceLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.ThirdGrade')" prop="thirdProvinceLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.otherGrade')" prop="otherProvinceLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column :label="$t('statisticsOfAwards.total')" prop="sumProvinceLevel" show-overflow-tooltip></el-table-column>
                            </el-table-column>
                            <el-table-column align='center' :label="$t('statisticsOfAwards.municipal')" show-overflow-tooltip>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.specialGrade')" prop="topCityLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.firstGrade')" prop="firstCityLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.secondGrade')" prop="secondCityLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.ThirdGrade')" prop="thirdCityLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column width="120%" :label="$t('statisticsOfAwards.otherGrade')" prop="otherCityLevel" show-overflow-tooltip></el-table-column>
                                <el-table-column :label="$t('statisticsOfAwards.total')" prop="sumCityLevel" show-overflow-tooltip></el-table-column>
                            </el-table-column>
                            <el-table-column align='center' :label="$t('statisticsOfAwards.schoolLevel')" prop="sumSchoolLevel" show-overflow-tooltip></el-table-column>
                        </el-table>
                        <el-row type="flex" class="row-bg" justify="end">
                            <el-col>
                                <el-pagination
                                    :current-page="queryForm.pageNum_"
                                    :page-sizes="[20, 40, 80, 100]"
                                    :page-size="queryForm.pageSize_"
                                    :total="queryForm.total_"
                                    layout="total, sizes, prev, pager, next, jumper"
                                    style="float:right;margin-top:10px"
                                    @size-change="handleSizeChange"
                                    @current-change="handleCurrentChange"
                                >
                                </el-pagination>
                            </el-col>
                        </el-row>
                    </el-tab-pane>
                </el-tabs>
                
            </el-card>
        </el-card>
    </div>
</template>

<script>
import { queryDic } from 'common/src/api/dictionary'
import UTILS from 'common/src/utils/utils'
import competiManagementApi from 'common/src/api/subjectCompetition/competiManagement'
import interManagementApi from 'common/src/api/externalExchange/interdiSciplinaryManagement'
export default {
    props: {
        compile: {
            type: String,
            default: ''
        }
    },
    data() {
        let cannotEnter = (rule, value, callback) => {
            let reg = /[`$]/im
            if (reg.test(value)) {
                return callback(new Error(this.$t('statisticsOfAwards.donotEnterSpecial')))
            } else if (value === '' || value === null) {
                return callback(new Error(this.$t('statisticsOfAwards.pleaseEnter')))
            }
            return callback()
        }
        return {
            queryForm: {
                pageNum_: 1,
                pageSize_: 20,
                total_: 0,
                condition: {
                    college: '', // 学院
                    year: '', // 年份
                    grade: '' // 年级
                }
            },
            options: {
                batch: [], // 竞赛级别
                match: [], // 参赛形式
                // time: [], // 获奖时间
                prize: [], // 奖项名称
                name: [], // 姓名
                departmentId: [] // 学院
            },
            dataList: [],
            activeName: 'year'
        }
    },
    mounted() {
        this.getOptions()
        this.awardInfoStatistics(this.queryForm)
    },
    methods: {
        addClick() {
            this.dynamicValidateForm.domains.push(
                { orgName: '',awardsDate: '',match: '',studentAwardsInfoList:[{}] }
            )
        },
        reback() {
            this.$emit('change-exam')
        },
        onSubmit() {
            this.awardInfoStatistics(this.queryForm)
        },
         // 重置
        reset() {
            for (let key in this.queryForm.condition) {
                this.queryForm.condition[key] = '';
            }
            this.queryForm.pageNum_ = 1
            this.awardInfoStatistics(this.queryForm)
        },
        // 学号改变获取数据
        remoteMethodTow(query) {
            if (query) {
                setTimeout(() => {
                    interManagementApi.getStudents(query).then(res => {
                        this.options.name = res.data
                    })
                }, 200)
            } else {
                this.options.name = []
            }
        },
        // 学号改变获取数据
        changeInput(val) {
            if (val) {
                interManagementApi.getStudents(val).then(res => {
                    this.options.name = res.data
                })
            } else {
                this.options.name = []
            }
            if (this.options.name) {
                this.options.name.forEach(el => {
                    if (val === el.studentId) {
                        this.options.name.push(el)
                    }
                })
            }
        
        },
        getOptions() {
            // 筛选条件字典查询
            let data = {
                lang: this.$store.getters.language || 'cn',
                type: 'allChild',
                keys: ['X_YX', 'G_XBIE', 'JSGL_JSJB', 'G_GJQU', 'JSGL_CSXS', 'JSGL_JXMC']
            }
            queryDic(data).then(res => {
                UTILS.fillSelect(
                    {
                        batch: 'JSGL_JSJB',
                        departmentId: "X_YX",
                        sex: 'G_XBIE',
                        match: 'JSGL_CSXS',
                        prize: 'JSGL_JXMC'
                    },
                    res.data,
                    this.options
                )
            })
        },
        // tab栏切换
        handleClick(val) {
            // console.log(val.name)
            this.queryForm.pageNum_ = 1
            this.awardInfoStatistics(this.queryForm)
        },
        awardInfoStatistics(data) {
            if(this.activeName === 'year') {
                let param = {
                    "year": data.condition.year,
                    "college": data.condition.college,
                    "grade": data.condition.grade
                }
                competiManagementApi.awardInfoStatistics(param).then(res => {
                    this.dataList = res.data
                    // this.queryForm.total_ = res.data.total_
                })
            } else {
                competiManagementApi.awardInfoCollege(data).then(res => {
                    this.dataList = res.data.list
                    this.queryForm.total_ = res.data.total_
                })
            }
        },
        // 导出
        exportFile() {
            if(this.activeName === 'year') {
                let param = {
                    "currentGrade": this.queryForm.condition.year,
                    "college": this.queryForm.condition.college
                }
                competiManagementApi.awardInfoStatisticsExport(param)
            } else {
                let param = {
                    "pageNum_": this.queryForm.pageNum_,
                    "pageSize_": -1,
                    "condition": {
                        "college": this.queryForm.condition.college,
                        "year": this.queryForm.condition.year
                    }
                }
                competiManagementApi.awardInfoCollegeExport(param)
            }
        },
        // 分页
        handleSizeChange(val) {
            this.queryForm.pageSize_ = val
            this.queryForm.pageNum_ = 1
            this.awardInfoStatistics(this.queryForm)
        },
        // 分页
        handleCurrentChange(val) {
            this.queryForm.pageNum_ = val
            this.awardInfoStatistics(this.queryForm)
        }
    },
}
</script>

<style></style>

